const Config = require("../model/config.model");

const verifyConfigExists = async (ctx, next) => {
  const { name } = ctx.request.body;

  const result = await Config.findOne({
    where: { name },
  });
  if (result) {
    return ctx.fail(409, "问卷名已存在");
  }
  await next();
};

module.exports = {
  verifyConfigExists,
};
